class Solution(object):
    def merge(self, nums1, m, nums2, n):
        """
        :type nums1: List[int]
        :type m: int
        :type nums2: List[int]
        :type n: int
        :rtype: void Do not return anything, modify nums1 in-place instead.
        """
        count = 0
        for i in range(len(nums2)):
            while (nums1[count] < nums2[i] and count <= m+i-1):
                count+=1
            nums1.insert(count,nums2[i])
            count = count+1
            del nums1[-1]
        return nums1



        # if len(nums1)==1:
        #     del nums1[m:]
        #     nums1.extend(nums2)
        # else:
        #     j ,i  = 0,0
        #     del nums1[m:]
        #     while i<m-1 and j<n-1:
        #         if nums1[i] < nums2[j]:
        #             i+=1
        #         else:
        #             nums1.insert(i+1,nums2[j])
        #             i+=2
        #             j+=1
        #
        #     if j < n:
        #         nums1.extend(nums2[j:])

nums1 = [1,2,3,0,0,0]
nums2 = [2,5,6]
m = 3
n = 3
s = Solution()
h= s.merge(nums1,m,nums2,n)
print(h)



